﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tuxedo.Compile;
using Tuxedo.Link.Passes;

namespace Tuxedo.Link
{
	internal class Linker
	{
		private static readonly Pass[] LINK_PASSES = new Pass[] {
			new Flatten()
		};

		public Class[] Link(ICollection<FPClass> fpClasses)
		{
			List<Class> output = new List<Class>();

			foreach (FPClass fpClass in fpClasses)
			{
				output.Add(new Class(fpClass));
			}

			Class[] classes = output.ToArray();

			PassContext context = new PassContext();

			foreach (Pass pass in LINK_PASSES)
			{
				pass.Apply(context, classes);
			}

			return classes;
		}
	}
}
